package come.tool.FightingEffect;

import org.come.Jpanel.TestPetJpanel;
import org.come.Jpanel.ZhuJpanel;
import org.come.entity.RoleSummoning;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.Article;
import org.come.until.UserMessUntil;

import com.tool.PanelDisplay.PetPanelShow;
import com.tool.role.RoleData;
import com.tool.tcp.GetTcpPath;
import come.tool.Fighting.FightingManData;
import come.tool.Fighting.FightingMixDeal;
import come.tool.Fighting.FightingState;
import come.tool.Fighting.Fightingimage;
import come.tool.Fighting.SkillSpell;
import come.tool.Fighting.StateProgress;

public class Pet implements Effect{

	@Override
	public StateProgress analysisAction(FightingState State, int path) {
		// TODO Auto-generated method stub
		if ("召回".equals(State.getStartState())) {
			FightingMixDeal.depath(State.getCamp(), State.getMan());
			FightingMixDeal.buffUtil.CS(State.getBuff(), FightingMixDeal.camp);
			return null;
		}
		FightingManData bb=State.getFightingManData();
		int myman=FightingMixDeal.myman()+5;
		if (bb.getCamp()==FightingMixDeal.camp&&bb.getMan()==myman) {
			RoleSummoning pet=Article.bb(bb.getId());
			if (pet!=null) {
				UserMessUntil.setChosePetMes(pet);
				//将宠物头像框设置为有头像
				ZhuJpanel.setLabpetimg("img/newHead/p"+pet.getSummoningskin()+".png");
				//绘制召唤兽 3条
				Article.souxie(pet);
				PetPanelShow.ShowMesForJpanel();
				if (!"闪现".equals(State.getStartState())) {
					String mes = Agreement.getAgreement().rolechangeAgreement("P"+pet.getSid().toString());
					SendMessageUntil.toServer(mes);
					// 设置自身携带的宠物id
					RoleData.getRoleData().getLoginResult().setSummoning_id(pet.getSid());
					TestPetJpanel.showStar();
				}
			}
		}
		
		FightingMixDeal.depath(bb.getCamp(), bb.getMan());
		Fightingimage fightingimage=new Fightingimage(bb,FightingMixDeal.camp);
		FightingMixDeal.CurrentData.add(fightingimage);
		path=FightingMixDeal.CurrentData.size()-1;
		StateProgress progress=EffectType.getProgress(State, path);
		if ("闪现".equals(State.getStartState())) {
			SkillSpell skillSpell=new SkillSpell();
			skillSpell=new SkillSpell(GetTcpPath.getSkillTcp("1806"),fightingimage.getX(),fightingimage.getY());
			progress.setSpell(skillSpell);
		}
		
		return progress;
	}

}
